package com.gonsin.gview.model.table;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.gonsin.gview.model.GFormItemModel;
import com.gonsin.gview.model.i18n.TCloneable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@ApiModel("搜索栏的描述")
@Data
public class GSearchBarModel implements TCloneable<GSearchBarModel> {

    @ApiModelProperty("搜索过滤器的描述")
    private List<GFormItemModel> filters;

    @Override
    public GSearchBarModel tClone() {
        GSearchBarModel model = new GSearchBarModel();
        BeanUtil.copyProperties(this, model, CopyOptions.create().setIgnoreNullValue(true));
        if(filters != null){
            model.filters = new ArrayList<>();
            for(GFormItemModel f : filters){
                model.filters.add(f.tClone());
            }
        }
        return model;
    }
}
